<?php
namespace Home\Controller;

use Think\Controller;

class UserController extends Controller
{

    public function login()
    {
        C('LAYOUT_ON', 0);
        if (IS_POST) {
            $users = D('User');
            $username = I('POST.username', '', 'strval');
            $password = I('POST.password', '', 'md5');
            $where = array(
                'emp_account' => $username,
                'emp_pwd' => $password
            );
            $userInfo = $users->where($where)->find();
            if ($userInfo) {
                session('userinfo', $userInfo);
                $this->success('登录成功！', U('Index/index'));
            } else {
                $this->error('用户或者密码不正确');
            }
        } else {
            $this->display();
        }
    }
    
    public function infos(){
        phpinfo();
        exit();
    }

    public function profiler()
    {
        $userinfo = session('userinfo');
        $this->assign('userinfo', $userinfo);
        $this->display();
    }

    public function logout()
    {}
}